<template>
  <div id="app" >
<!--    <div  v-show="login==0">
      <router-view></router-view>
    </div>-->
    <div>
      <el-container class="full-height">
        <div v-if="this.$route.meta.isNotFound === false">
          <el-aside class="aside-border">
            <router-view name="menuView" />
          </el-aside>
        </div>
        <el-main>
          <div v-if="this.$route.meta.isNotFound === false">
            <el-header>
              <router-view name="topView" />
            </el-header>
          </div>
          <el-main class="inner-main">
            <router-view></router-view>
          </el-main>
        </el-main>
      </el-container>

    </div>




  </div>
</template>

<style lang="scss">
html, body, #app {
  height: 100%;
  margin: 0;
}

.full-height {
  height: 100vh; /* 让 el-container 高度填满整个浏览器窗口 */
}

.el-aside,
.el-main {
  height: 100%; /* 确保子元素也填满父容器的高度 */
}

.inner-main {
  height: calc(100% - 64px); /* 调整内部主内容的高度，假设 header 高度为 64px */
}
.aside-border {
  border-right: 2px solid black; /* 调整边框宽度和颜色 */
}

</style>
<script>
import LoginView from "@/views/LoginView.vue";
import Utils from '@/store/util.js';
import {EventBus} from "@/utils/event-bus";
export default {
  data() {
    return {
      login:1
    };
  },
  created() {

    EventBus.$on('redirectToHome', this.handleRedirectToHome);

  },
  mounted(){
    document.title = '智慧社区管理平台';
    var that = this;

    Utils.$on('loginout',function(msg){
      that.setLogin(0);
      localStorage.removeItem('userToken');
      //localStorage.removeItem('adminPermissions');
      that.$router.push({name:"login"});
    });

  },
  beforeCreate() {


  },
  beforeDestroy() {
    EventBus.$off('redirectToHome', this.handleRedirectToHome);
  },
  methods:{
    setLogin(status){
      this.login = status;
    },
    handleRedirectToHome() {
      if (this.$route.path !== '/') {
        this.$router.push('/');
      }
    },
  }
}
</script>
